package com.hy.service.impl;

import com.hy.bean.RespPageBear;
import com.hy.dao.CardDao;
import com.hy.service.CardPageService;
import com.hy.vo.CardUser;

import java.util.List;

/**
 *
 *
 * @Description: 分页
 * @Author: zhangzhengwei2006
 * @Date: 2024-01-05 20:53
 *
 *
 */
public class CardPageServiceImpl implements CardPageService {

    @Override
    public RespPageBear list(Integer currentPage, Integer pageSize) throws Exception {
        CardDao cardDao = new CardDao();
        RespPageBear pageBear = new RespPageBear();
        List<CardUser> cardUsers = cardDao.selectPage(currentPage, pageSize);
        Long total = cardDao.selectTotal();
        pageBear.setData(cardUsers);
        long pageCount = total%pageSize == 0 ? total / pageSize : total / pageSize + 1;
        pageBear.setTotalPages(pageCount);
        pageBear.setCurrentPage(currentPage);
        pageBear.setPageSize(pageSize);
        return pageBear;
    }
}
